<%@ page language="java" import="java.util.*"  pageEncoding="utf-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<% String path=request.getContextPath(); String basePath=request.getScheme()+ "://" + request.getServerName() + ":" + request.getServerPort() + path+ "/"; %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html xmlns="http://www.w3.or/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<base href="<%=basePath %>">
<title>产品定制</title>
<%@ include file="/WEB-INF/jsp/common/common.jsp" %>
<script src="<%=path%>/js/jquery.divbox.js" type="text/javascript"></script>
<script type="text/javascript">
//保存
function updateOrInsertPlanInfo(){
	var planNo = $("#planChoose").val().split(" --- ")[0];
	var planDesc = $("#planDesc").val();
	var planSpecial1 = $("#planSpecial1").val();
	var planSpecial2 = $("#planSpecial2").val();
	var planSpecial3 = $("#planSpecial3").val();
	var planIntro = $("#planIntro").val();
	var planNotice = $("#planNotice").val();

	
	var param = ({planNo:planNo,planDesc:planDesc,planSpecial1:planSpecial1,planSpecial2:planSpecial2,planSpecial3:planSpecial3,planIntro:planIntro,planNotice:planNotice});
	
	$.openLoading();
	$.ajax({
		url : "prodManage/saveOrUpdateInfo",
		type : 'POST',
		async : false,
		dataType:'json',
		data:param,
		success:function(){
			$.closeLoading();
			$.message("success", "数据更新成功");
			return;
		},
		error:function(plan){
			$.message("error", "数据更新失败");
			$.closeLoading();
		}
		
		
	
	});
}

//回写
function writeback(){
	var radioTemple = $("input[name='radioTemple']:checked");
	var planNo= radioTemple.parent().parent().children("td:eq(1)").html();
	var planName= radioTemple.parent().parent().children("td:eq(2)").html();
	closePlanDiv();	
	$("#planChoose").val(planNo+" --- "+planName);	
	var param = ({planNo:planNo});
	$.openLoading();
	$.ajax({
		url : "prodManage/queryPlanInfosByPlanNo",
		type : 'POST',
		async : false,
		dataType:'json',
		data:param,
		success:function(info){
			$("#planDesc").val(info.planDesc);
			$("#planSpecial1").val(info.planSpecial1);
			$("#planSpecial2").val(info.planSpecial2);
			$("#planSpecial3").val(info.planSpecial3);
			$("#planIntro").val(info.planIntro);
			$("#planNotice").val(info.planNotice);
			$.closeLoading();
		}
	});
}

function closePlanDiv(){
	$('#addPlanDiv').CloseDiv()
}
function fvreset(){
	$('#planCode').val('');
	$('#planName').val('');
}
function openPlanDiv(pageCount){
	if(!pageCount){
		fvreset();
		pageCount=1;
	}
	var planCode=$('#planCode').val();
	var planName=$('#planName').val();
	loadPlan({size:8,current:pageCount,planCode:planCode,planName:planName});
}
function loadPlan(param){
	$.openLoading();
	$.ajax({
		url : "prodManage/queryPlanList",
		type : 'POST',
		async : true,
		dataType:'json',
		data:param,
		success : function(page) {
			$.closeLoading();
			if($.validate(page))return;
			var firstbutton ="<input class='input_fxk' name='radioTemple' type='radio' value=''>";
			var tableContent = creatTable1("PLAN_NO,PLAN_NAME,PARTNER_NO",page,firstbutton,null);
			var tableObj = $("#productTempletTable");
			tableObj.find("tbody").remove();
			tableObj.append(tableContent);
			var strPage = creatChannelPage(page.current,8,page.maxPage,"99");
			var pageDIV = $("#productTempletpageDIV");
			pageDIV[0].innerHTML="";
			pageDIV.append(strPage);

			 bindredio(); 
			$("#addPlanDiv").OpenDiv();
		}
	});
	
	function bindredio(){
		$("input[name='radioTemple']").click(function(){
			$("input[name='radioTemple']").parent().parent().removeClass("table_highlighter");
			$(this).parent().parent().addClass("table_highlighter");

	   	});
	}
}
//取消
function cancel(){
	window.history.back();
}
</script>
</head>
<body>
	<div class="current">
		<table class="current_table_1">
			<tbody>
				<tr class="f2">
				<td><img src="./images/current_1.jpg"></td>
				 <td class="current_table_1_td">
                   <img src="images/current_1.png">&nbsp;您现在的位置：&nbsp;
                     <span style=" color:#136bab; ">界面出单管理
                     <span style="padding:0 5px; font-weight:bold; line-height:28px;">&gt;</span>产品定制
                 </span>
                 </td>
                 <td><img src="./images/current_3.jpg"></td>
				</tr>
			</tbody>
		</table>
	</div>
	<form id="inputForm">
	        <table class="table_05">
              <tbody>
	              <tr>
	                  <td colspan="4" style=" font-size:12px; font-weight:bold; text-align:left;color:#3876bf; line-height:17px; background-image:url(images/centent_1.jpg)">
							方案界面定制
	                  </td>
	              </tr>
	              <tr>
	                  <th>方案选择：</th>
	                  <td colspan="1" width="55%"> 
						<input id="planChoose"  type="text" readonly="true" style=" background-color: #ccc;width: 400px" class="input_text" >
						<input type="button"   id="searchBtn" value="选择方案" onClick="openPlanDiv()"/>	
	                  </td>
	                  <td rowspan="1">展示页面</td>
	              </tr>
	              <tr>
	             	  <th>方案描述：</th>
	                  <td colspan="1">
						<textarea id="planDesc" class="textarea_1" style="width: 400px;resize:none" rows="4"  onkeydown="false"  type="text" ></textarea>	                 
	                  </td>
	                  <td rowspan="6"><img src="<%=path %>/images/scanIndex.png"></td>
	               </tr>
	              <tr>
	               <th>方案特色1：</th>
		                <td colspan="1" >
		                  <input id="planSpecial1" style="width: 400px"  onkeydown="false"  type="text" />(0~15个汉字)
		                </td>
		          </tr>
		          <tr>
	               <th>方案特色2：</th>
		                <td colspan="1" >
		                    <input id="planSpecial2" style="width: 400px"  onkeydown="false"  type="text" />(0~15个汉字)
		                </td>
		          </tr>
		          <tr>
	               <th>方案特色3：</th>
		                <td colspan="1" >
		                   <input id="planSpecial3" style="width: 400px"  onkeydown="false"  type="text" />(0~15个汉字)
		                </td>
		          </tr>
	              <tr>
	               		 <th>产品介绍：</th>
	                 	 <td colspan="1" >
	                  		<textarea name="planIntro" id="planIntro" rows="4" class="textarea_1" style="width: 400px;resize:none;"></textarea>
	                  	 </td>
	              </tr>
		          <tr>
	               		 <th>购买须知：</th>
	                 	 <td colspan="1" >
	                  		<textarea name="planNotice" id="planNotice" rows="4" class="textarea_1" style="resize:none;width: 400px;"></textarea>
	                  	 </td>
	              </tr>
		          
		</tbody>
		</table>
		</form>
		<div align="center" style="margin-top: 7px;">
		<input id="sub" class="input_button_1" name="" type="button"
			value="保存" onclick="updateOrInsertPlanInfo()">&nbsp;&nbsp; 
			<input
			class="input_button_1" name="" onclick="cancel()" type="button"
			value="取消">
		</div>
		
		<!--   	添加模板 DIV 默认隐藏-->
  		<div id="addPlanDiv"  style="display:none;width:80%;">
			<input type="hidden" id="row_num" name="row_num" value="0"/>
			<div class="table_title_div">
					<table class="table_title" style='width:100%;'>
						<tr>
						<td width="10%"></td>
						<td width="80%" id="interfaceName"></td>
						<td width="10%" align="right"><img src="<%=path%>/images/closedown.gif" alt="关闭"  onclick="closePlanDiv()"/></td>
						</tr>
					
					</table>
			</div>
		<form id="inputForm" action="save.jhtml" method="post" enctype="multipart/form-data">
			
			<table class="table_02" id="addtempletTable" style="height:180px; " align="center" >
				<tbody>
					<tr>
						<td>
							<table class="search_table">
								<tbody>
									<tr height="30px">
										<td width="40%" height="30px">方案代码：
											<input name="txt3" id="planCode" type="text" class="input_text" value="" style="width:220px;">
										</td>
										<td width="40%" height="30px">方案名称：
											<input name="txt3" id="planName" type="text" class="input_text" value="" style="width:220px;">
										</td>
										<td width="20%" height="30px">
										   <input type="button" class="input_button_1" id="searchBtn" value="查询" onclick="openPlanDiv(1)">&nbsp;
										   <input type="button" class="input_button_1" id="searchBtn" value="重置" onclick="fvreset()">
										</td>
									</tr>	
								</tbody>
							</table>
						</td>
					</tr>
					<tr>
						<td>
							<table id="productTempletTable"  class="content_table_1">
								<thead>
									<tr class="f1">
					                  <th style="width:5%">选择</th>
					                  <th style="width:15%">方案代码</th>
					                  <th style="width:20%">方案名称</th>
					                  <th style="width:20%">合作伙伴代码</th>
					              	</tr>
								</thead>
								<tbody>
								</tbody>
							</table>
							<div id="productTempletpageDIV"  class="page"></div>
						</td>
					</tr>
				</tbody>
			</table>
			<div align="center">
			 <input class="input_button_3" name="" type="button" onclick="writeback()" value="保存">&nbsp;&nbsp;
	         <input class="input_button_3" name="" type="button" onclick="closePlanDiv()" value="取消">
			</div>
		</form>
	</div>
			
</body>
</html>